package io.yuncheng.modules.sys.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.yuncheng.modules.sys.entity.SubCascadePlatformEntity;
import io.yuncheng.modules.sys.entity.SubCascadePlatformLogDetailVo;
import io.yuncheng.modules.sys.service.SubCascadePlatformService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.yuncheng.modules.sys.entity.SubCascadePlatformLogEntity;
import io.yuncheng.modules.sys.service.SubCascadePlatformLogService;
import io.yuncheng.common.utils.PageUtils;
import io.yuncheng.common.utils.R;



/**
 * 级联表日志记录表
 *
 * @author jared
 * @email 15721509625@163.com
 * @date 2021-01-06 17:46:00
 */
@RestController
@RequestMapping("sys/subcascadeplatformlog")
public class SubCascadePlatformLogController {
    @Autowired
    private SubCascadePlatformLogService subCascadePlatformLogService;
    @Autowired
    private SubCascadePlatformService service;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:subcascadeplatformlog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = subCascadePlatformLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		SubCascadePlatformLogEntity subCascadePlatformLog = subCascadePlatformLogService.getById(id);

        return R.ok().put("subCascadePlatformLog", subCascadePlatformLog);
    }    /**
     * 信息
     */
    @RequestMapping("/info-detail/{id}")
    public R infoDetail(@PathVariable("id") Long id){
        SubCascadePlatformEntity byId = service.getById(id);
        List<SubCascadePlatformLogDetailVo> subCascadePlatformLogDetailVos = subCascadePlatformLogService.queryListCollectByDeptId(byId.getCascadeId());
        return R.ok().put("data", subCascadePlatformLogDetailVos);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SubCascadePlatformLogEntity subCascadePlatformLog){
		subCascadePlatformLogService.save(subCascadePlatformLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SubCascadePlatformLogEntity subCascadePlatformLog){
		subCascadePlatformLogService.updateById(subCascadePlatformLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		subCascadePlatformLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
